<template>
  <el-card
    shadow="hover"
    :style="{ borderLeft: `4px solid ${color}` }"
    class="stat-card"
  >
    <div class="flex-container">
      <div
        class="stat-icon"
        :style="{ backgroundColor: color + '20' }"
      >
        <i :class="icon" :style="{ color: color }"></i>
      </div>
      <div class="stat-content">
        <div class="stat-title">{{ title }}</div>
        <count-to
          class="stat-value"
          :end-val="value"
          :duration="2000"
        />
      </div>
    </div>
  </el-card>
</template>

<script>
import CountTo from 'vue-count-to'

export default {
  name: 'StatCard',
  components: { CountTo },
  props: {
    title: String,
    value: Number,
    icon: String,
    color: String
  }
}
</script>

<style scoped>
.stat-card {
  margin-bottom: 0;
}

.stat-card >>> .el-card__body {
  padding: 16px;
}

.flex-container {
  display: flex;
  align-items: center;
}

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  margin-right: 15px;
}

.stat-icon i {
  font-size: 24px;
}

.stat-title {
  color: #999;
  font-size: 14px;
  margin-bottom: 5px;
}

.stat-value {
  font-size: 24px;
  font-weight: bold;
  color: #333;
}
</style>
